Fix tool argument parsing for hyphenated parameter names #1090
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #924
Summary
This PR fixes a bug where tool arguments with hyphenated names (e.g.,
"file-path","file-edits") failed to parse correctly, causing tool functions to receivenilarguments instead of the actual values from the LLM.Root Cause
When tool argument names contain hyphens, the code was using
make-symbolto create JSON schema property keys. This created uninterned symbols whose names include the leading colon (e.g.,":file-path"), which then became JSON keys. When the LLM returned these keys and the JSON was parsed back, there was a mismatch:make-symbol): JSON key":file-path"→ parsed as keyword::file-pathintern): Looks for keyword:file-pathplist-getreturnsnil, tool function receivesnilargumentsChanges
1. Changed
make-symboltointern(3 files)gptel--parse-toolsimplementationThis ensures proper keywords are created that survive JSON round-trip correctly.
2. Improved error handling in gptel-openai.el
ignore-errorswithcondition-casethat logs parse failuresWhy This Fix is Correct
The retrieval code in
gptel-request.el:1699usesintern:By using
internduring schema creation as well, both sides create the same keyword object, soplist-getsucceeds.Testing
The issue reporter confirmed that:
This fix ensures both modes work correctly by addressing the root cause.
Impact
🤖 Generated with Claude Code